| Total Complexity | 6 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import dP from 'dot-prop'; |
||
| 4 | export default class BaseReporter { |
||
| 5 | constructor(file) { |
||
| 6 | this.file = file; |
||
| 7 | } |
||
| 8 | |||
| 9 | _init() {} |
||
| 10 | |||
| 11 | _build(actions, { groupBy = [] } = {}) { |
||
| 12 | const map = new Map(); |
||
| 13 | const groups = {}; |
||
| 14 | |||
| 15 | for (const a of actions) { |
||
| 16 | const groupValues = groupBy.map(key => dP.get(a, key)); |
||
| 17 | |||
| 18 | findGroup.call(this, groups, groupValues, a.id); |
||
| 19 | map.set(a.id, a); |
||
| 20 | } |
||
| 21 | |||
| 22 | return { groups, map }; |
||
| 23 | } |
||
| 24 | |||
| 25 | getHash(action) { |
||
| 26 | return action.id; |
||
| 27 | } |
||
| 28 | } |
||
| 29 |